package cn.ray_land.dlprint.main;

import java.util.List;
import cn.ray_land.dlprint.data.SliceData;
import cn.ray_land.dlprint.data.SliceDataRepository;
import cn.ray_land.dlprint.data.SliceDataResource;
import static cn.ray_land.dlprint.util.Preconditions.checkNotNull;

/**
 * Created by gw on 2016/8/2.
 */

public class MainPresenter implements MainContract.Presenter{

    private MainContract.View mView;

    public MainPresenter(MainContract.View view){
        checkNotNull(view);
        this.mView = view;
    }

    @Override
    public void loadSliceDatas() {
        mView.showLoadingIndicator(true);
        SliceDataRepository.getInstance().getDatas(new SliceDataResource.LoadDataCallback() {
            @Override
            public void onDataLoaded(List<SliceData> datas) {
                mView.showSliceDatas(datas);
                mView.showLoadingIndicator(false);
            }

            @Override
            public void onDataNotAvailable() {
                mView.showLoadingIndicator(false);
            }
        });
    }
}
